home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Comm / AmiTCP30b2.lha / src / appl / napsaterm / mymap.c < prev    next >
C/C++ Source or Header  |  1994-05-14  |  11KB  |  331 lines

  1. /* $Id: mymap.c,v 3.1 1994/02/25 02:33:38 ppessi Exp $
  2.  *
  3.  * keymap.c --- a (Finnish) keymap for my taste
  4.  *
  5.  * Author: ppessi <Pekka.Pessi@hut.fi>
  6.  *
  7.  * Copyright © 1993 Pekka Pessi
  8.  *
  9.  * Created      : Fri Apr  2 01:13:20 1993 ppessi
  10.  * Last modified: Fri Feb 25 02:09:39 1994 ppessi
  11.  *
  12.  * Compile with gcc: gcc -o ss -nostdlib -DKEYMAPNAME=ss mymap.c 
  13.  * Compile with sc : sc resopt link to ss batch Nostartup stripdebug smalldata +
  14.  *                   DEF KEYMAPNAME=ss stringmerge data=FAR mymap.c
  15.  * DICE does not handle this kludge.
  16.  *
  17.  * When compiling you will get a gazillion of warnings. Ignore them.
  18.  *
  19.  * Note that KEYMAPNAME *MUST* be same as 
  20.  * the seglist file in devs:keymaps/ directory. 
  21.  */
  22.  
  23. #include <devices/keymap.h>
  24.  
  25. #ifndef KEYMAPNAME
  26. #define KEYMAPNAME "mymap"
  27. #endif
  28.  
  29. extern UBYTE KeyMapName[];
  30. extern UBYTE LoKeyMapTypes[64];
  31. extern ULONG LoKeyMap[64];
  32. extern UBYTE LoCapsable[8];
  33. extern UBYTE LoRepeatable[8];
  34. extern UBYTE HiKeyMapTypes[64];
  35. extern ULONG HiKeyMap[64];
  36. extern UBYTE HiCapsable[8];
  37. extern UBYTE HiRepeatable[8];
  38.  
  39. struct KeyMapNode s =
  40. {
  41.   { NULL, NULL, 0, 0, KeyMapName },
  42.   {
  43.     LoKeyMapTypes,
  44.     LoKeyMap,
  45.     LoCapsable,
  46.     LoRepeatable,
  47.     HiKeyMapTypes,
  48.     HiKeyMap,
  49.     HiCapsable,
  50.     HiRepeatable
  51.   }
  52. };
  53.  
  54. #define KCF_SHIFT_STRING KCF_STRING|KCF_SHIFT
  55. #define KCF_SHIFT_CONTROL KCF_SHIFT|KCF_CONTROL
  56. #define CSI "\233"
  57.  
  58. /* Notice byte sex */
  59. /* c1 == plain, c2 == shifted, c3 == alt, c4 == shift+alt */
  60. #define VANILJA(c1, c2, c3, c4) \
  61.   ((((c4)&0xff)<<24)|(((c3)&0xff)<<16)|(((c2)&0xff)<<8)|((c1)&0xff))
  62. /* Notice bit sex */
  63. #define BITS(b0, b1, b2, b3, b4, b5, b6, b7) \
  64.   (((b0)&1)<<0|((b1)&1)<<1|((b2)&1)<<2|((b3)&1)<<3| \
  65.    ((b4)&1)<<4|((b5)&1)<<5|((b6)&1)<<6|((b7)&1)<<7)
  66.  
  67. #define DEAD(name, d1, d2, c1, c2) \
  68.   static struct { char ded[8]; } name = \
  69.   { DPF_DEAD, d1, DPF_DEAD, d2, 0, c1, 0, c2 }
  70. #define ALTDEAD(name, d1, c, C) \
  71.   static struct { char ded[16]; } name = { 0, c, 0, C, DPF_DEAD, d1, DPF_DEAD, d1, \
  72.              0, c & 0x1f, 0, c & 0x1f, \
  73.              0, c & 0x1f | 0x80, 0, c & 0x1f | 0x80 }
  74. /* m and M are 6 chars long */
  75. #define ACCENTED(name, c, m, M, a, A) \
  76.   static struct { char normal[16]; char low[6]; char hi[6]; } \
  77.   name = {{ DPF_MOD, 16, DPF_MOD, 22, \
  78.        0, m, 0, M, 0, c & 0x1f, 0, c & 0x1f, \
  79.        0, c & 0x1f | 0x80, 0, c & 0x1f | 0x80 }, a , A }
  80.  
  81. #define strsize(s) (sizeof(s)-1)
  82.  
  83. #define STRING(name, len, s) \
  84.   static  struct { char offsets[2]; char st[len]; } \
  85.   name = { {len, 2}, s }
  86.  
  87. #define STRING_S(name, l, s, sl, ss) \
  88.   static struct { char offsets[4]; char st[l]; char sts[sl]; } \
  89.   name = { {l, 4, sl, 4+l }, s, ss }
  90.  
  91. #define STRING_SA(name, l, s, sl, ss, al, sa, asl, sas) \
  92.   static struct { char offsets[8]; \
  93.           char st[l]; char sts[sl]; char sta[al]; char stas[asl]; } \
  94.   name = { {l, 8, sl, 8+l, al, 8+l+sl, asl, 8+l+sl+al }, s, ss, sa, sas }
  95.  
  96. UBYTE LoKeyMapTypes[64] =
  97. {
  98.   /* `~       1!                 2"          3#   */
  99.   KC_VANILLA, KCF_SHIFT|KCF_ALT, KC_VANILLA, KCF_SHIFT|KCF_ALT,
  100.   /* 4$ 5% ; 6& ; 7/ */
  101.   KCF_SHIFT|KCF_ALT, KCF_SHIFT|KCF_ALT, KC_VANILLA, KCF_SHIFT|KCF_ALT,
  102.   /* 8( 9) 0= +? */
  103.   KCF_SHIFT|KCF_ALT, KCF_SHIFT|KCF_ALT, KCF_SHIFT|KCF_ALT, KC_VANILLA,
  104.   /* ´` \| nil p0 */
  105.   KCF_DEAD|KCF_SHIFT|KCF_ALT, KC_VANILLA, KCF_NOP, KC_NOQUAL,
  106.   /* qQ wW eE rR */
  107.   KC_VANILLA, KC_VANILLA, KCF_DEAD+KC_VANILLA, KC_VANILLA,
  108.   /* tT yY uU iI */
  109.   KC_VANILLA, KCF_DEAD|KC_VANILLA, KCF_DEAD|KC_VANILLA, KCF_DEAD|KC_VANILLA,
  110.   /* oO pP åÅ ¨^ */
  111.   KCF_DEAD|KC_VANILLA, KC_VANILLA, KC_VANILLA, KCF_DEAD|KC_VANILLA,
  112.   /* nil p1 p2 p3 */
  113.   KCF_NOP, KC_NOQUAL, KC_NOQUAL, KC_NOQUAL,
  114.   /* aA sS dD fF */
  115.   KCF_DEAD|KC_VANILLA, KC_VANILLA, KC_VANILLA, KCF_DEAD|KC_VANILLA,
  116.   /* gG hH jJ kK */
  117.   KCF_DEAD|KC_VANILLA, KCF_DEAD|KC_VANILLA,
  118.   KCF_DEAD|KC_VANILLA, KCF_DEAD|KC_VANILLA,
  119.   /* lL öÖ äÄ \'* */
  120.   KC_VANILLA, KCF_SHIFT|KCF_ALT, KCF_SHIFT|KCF_ALT, KCF_SHIFT_STRING|KCF_ALT,
  121.   /* nil p4 p5 p6 */
  122.   KCF_NOP, KC_NOQUAL, KC_NOQUAL, KC_NOQUAL,
  123.   /* <> zZ xX cC */
  124.   KC_VANILLA, KC_VANILLA, KC_VANILLA, KC_VANILLA,
  125.   /*  vV bB nN mM */
  126.   KC_VANILLA, KC_VANILLA, KCF_DEAD|KC_VANILLA, KC_VANILLA,
  127.   /* ,;     .: -_ nil */
  128.   KCF_SHIFT|KCF_ALT, KCF_SHIFT|KCF_ALT, KC_VANILLA, KCF_NOP,
  129.   /* p. p7 p8 p9 */
  130.   KC_NOQUAL, KC_NOQUAL, KC_NOQUAL, KC_NOQUAL
  131. };
  132.  
  133. /* Dead keys */
  134. DEAD(key0C, 1, 2, '=', '+'); /* ´` accents */
  135. DEAD(key1B, 5, 3, ']', '}'); /* ¨^ accents */
  136. ALTDEAD(key23, 1, 'f', 'F'); /* ´ */
  137. ALTDEAD(key24, 2, 'g', 'G'); /* ` */
  138. ALTDEAD(key25, 3, 'h', 'H'); /* ^ */
  139. ALTDEAD(key26, 4, 'j', 'J'); /* ~ */
  140. ALTDEAD(key27, 5, 'k', 'K'); /* ¨ */
  141.  
  142. /* Deadable keys */
  143. ACCENTED(key12, 'e', '©', '©', "eéèêeë", "EÉÈÊEË");
  144. ACCENTED(key15, 'y', '¤', '¥', "yýyyyÿ", "YÝYYYY");
  145. ACCENTED(key16, 'u', 'µ', 'µ', "uúùûuü", "UÚÙÛUÜ");
  146. ACCENTED(key17, 'i', '¡', '¦', "iíìîiï", "IÍÌÎIÏ");
  147. ACCENTED(key18, 'o', 'ø', 'Ø', "oóòôõö", "OÓÒÔÕÖ");
  148. ACCENTED(key20, 'a', 'æ', 'Æ', "aáàâãä", "AÁÀÂÃÄ");
  149. ACCENTED(key36, 'n', '­', '¯', "nnnnñn", "NNNNÑN");
  150. /* space bar, no alt, no control */
  151. struct { char mod[4]; char low[6]; } key40 =
  152. { { DPF_MOD, 4, 0, '\240'}, " ´`^~¨" };
  153. /* Special key for #? */
  154. STRING_SA(key2B, 1, "\'", 1, "*", 2, "#?", 2, "[]");
  155. /* String keys */
  156. STRING(key5F, 3, CSI"?~");         /* Help */
  157. STRING_S(key42, 1, "\t", 2, CSI"Z");    /* tabulator */
  158. /* Cursor keys */
  159. STRING_S(key4C, 2, CSI"A", 2, CSI"T"); /* up */
  160. STRING_S(key4D, 2, CSI"B", 2, CSI"S"); /* down */
  161. STRING_S(key4E, 2, CSI"C", 2, CSI"@"); /* right */
  162. STRING_S(key4F, 2, CSI"D", 2, CSI"A"); /* left */
  163. /* Function keys */
  164. STRING_S(key50, 3, CSI"0~", 4, CSI"10~");
  165. STRING_S(key51, 3, CSI"1~", 4, CSI"11~");
  166. STRING_S(key52, 3, CSI"2~", 4, CSI"12~");
  167. STRING_S(key53, 3, CSI"3~", 4, CSI"13~");
  168. STRING_S(key54, 3, CSI"4~", 4, CSI"14~");
  169. STRING_S(key55, 3, CSI"5~", 4, CSI"15~");
  170. STRING_S(key56, 3, CSI"6~", 4, CSI"16~");
  171. STRING_S(key57, 3, CSI"7~", 4, CSI"17~");
  172. STRING_S(key58, 3, CSI"8~", 4, CSI"18~");
  173. STRING_S(key59, 3, CSI"9~", 4, CSI"19~");
  174.  
  175. ULONG LoKeyMap[64] =
  176. {
  177.   VANILJA('`','~','`','~'), VANILJA('1','!','¹','¹'),
  178.   VANILJA('2','"','@','²'), VANILJA('3','#','³','³'),
  179.   VANILJA('4','$','¢','¤'), VANILJA('5','%','¼','%'),
  180.   VANILJA('6','&','½','^'), VANILJA('7','/','¾','&'),
  181.   VANILJA('8','(','·','*'), VANILJA('9',')','«','('),
  182.   VANILJA('0','=','»',')'), VANILJA('+','?','-','_'),
  183.   (ULONG)&key0C,            VANILJA('\\','|','\\','|'),
  184.   0,                       '0',
  185.   VANILJA('q','Q','å','Å'), VANILJA('w','W','°','°'),
  186.   (ULONG)&key12,            VANILJA('r','R','®','®'),
  187.   VANILJA('t','T','þ','Þ'), (ULONG)&key15, /* '¥¤Yy' */
  188.   (ULONG)&key16,            (ULONG)&key17,
  189.   (ULONG)&key18,            VANILJA('p','P','¶','¶'),
  190.   VANILJA('å','Å','[','{'), (ULONG)&key1B,
  191.   0L, '1', '2', '3',
  192.   (ULONG)&key20,            VANILJA('s','S','ß','§'),
  193.   VANILJA('d','D','ð','Ð'), (ULONG)&key23,
  194.   (ULONG)&key24, (ULONG)&key25, (ULONG)&key26, (ULONG)&key27,
  195.   VANILJA('l','L','£','£'), VANILJA('ö','Ö',';',':'),
  196.   VANILJA('ä','Ä','\'','"'), (ULONG)&key2B,
  197.   0, '4', '5', '6',
  198.   VANILJA('<','>','\\','|'),VANILJA('z','Z','±','¬'),
  199.   VANILJA('x','X','×','÷'), VANILJA('c','C','ç','Ç'),
  200.   VANILJA('v','V','ª','ª'), VANILJA('b','B','º','º'),
  201.   (ULONG)&key36,            VANILJA('m','M','¸','¿'),
  202.   VANILJA(',',';',',','<'), VANILJA('.',':','.','>'),
  203.   VANILJA('-','_','/','?'),  0L,
  204.   '.', '7', '8', '9'
  205. };
  206.  
  207. UBYTE LoCapsable[8] =
  208. {
  209.   /*    `  1  2  3  4  5  6  7 */
  210.   BITS( 0, 0, 0, 0, 0, 0, 0, 0 ),
  211.   /*    8  9  0  + \´  \ NL p0 */
  212.   BITS( 0, 0, 0, 0, 0, 0, 0, 0 ),
  213.   /*    q  w  e  r  t  y  u  i */
  214.   BITS( 1, 1, 1, 1, 1, 1, 1, 1 ),
  215.   /*    o  p  å  ¨ NL p1 p2  3 */
  216.   BITS( 1, 1, 1, 0, 0, 0, 0, 0 ),
  217.   /*    a  s  d  f  g  h  j  k */
  218.   BITS( 1, 1, 1, 1, 1, 1, 1, 1 ),
  219.   /*    l  ö  ä  ' NL p4 p5  6 */
  220.   BITS( 1, 1, 1, 0, 0, 0, 0, 0 ),
  221.   /*    <  z  x  c  v  b  n  m */
  222.   BITS( 0, 1, 1, 1, 1, 1, 1, 1 ),
  223.   /*    ,  .  - NL p. p7 p8  9 */
  224.   BITS( 0, 0, 0, 0, 0, 0, 0, 0 )
  225. };
  226.  
  227. UBYTE LoRepeatable[8] =
  228. {
  229.   /*    `  1  2  3  4  5  6  7 */
  230.   BITS( 1, 1, 1, 1, 1, 1, 1, 1 ),
  231.   /*    8  9  0  +  ´  \ NL  0 */
  232.   BITS( 1, 1, 1, 1, 1, 1, 0, 1 ),
  233.   /*    q  w  e  r  t  y  u  i */
  234.   BITS( 1, 1, 1, 1, 1, 1, 1, 1 ),
  235.   /*    o  p  å  ¨ NL p1 p2  3 */
  236.   BITS( 1, 1, 1, 1, 0, 1, 1, 1 ),
  237.   /*    a  s  d  f  g  h  j  k */
  238.   BITS( 1, 1, 1, 1, 1, 1, 1, 1 ),
  239.   /*    l  ö  ä  ' NL p4 p5  6 */
  240.   BITS( 1, 1, 1, 1, 0, 1, 1, 1 ),
  241.   /*    <  z  x  c  v  b  n  m */
  242.   BITS( 1, 1, 1, 1, 1, 1, 1, 1 ),
  243.   /*    ,  .  - NL p. p7 p8  9 */
  244.   BITS( 1, 1, 1, 0, 1, 1, 1, 1 )
  245. };
  246.  
  247. UBYTE HiKeyMapTypes[64] =
  248. {
  249.   /* SPACE BACKSPACE TAB ENTER */
  250.   KCF_DEAD|KCF_ALT, KC_NOQUAL, KCF_SHIFT_STRING, KC_NOQUAL,
  251.   /* RETURN ESCAPE DELETE nil */
  252.   KCF_CONTROL, KCF_ALT, KCF_CONTROL, KCF_NOP,
  253.   /* nil nil p- nil */
  254.   KCF_NOP, KCF_NOP, KC_NOQUAL, KCF_NOP,
  255.   /* UP DOWN RIGHT LEFT  */
  256.   KCF_SHIFT_STRING, KCF_SHIFT_STRING, KCF_SHIFT_STRING, KCF_SHIFT_STRING,
  257.   /* F1  F2 F3 F4 */
  258.   KCF_SHIFT_STRING, KCF_SHIFT_STRING, KCF_SHIFT_STRING, KCF_SHIFT_STRING,
  259.   /* F5 F6 F7 F8 */
  260.   KCF_SHIFT_STRING, KCF_SHIFT_STRING, KCF_SHIFT_STRING, KCF_SHIFT_STRING,
  261.   /* F9  F10 [{ ]} */
  262.   KCF_SHIFT_STRING, KCF_SHIFT_STRING, KCF_SHIFT_CONTROL, KCF_SHIFT_CONTROL,
  263.   /* p/ p* p+ HELP */
  264.   KC_NOQUAL, KC_NOQUAL, KC_NOQUAL, KCF_STRING,
  265.   /* Left Shift Right ShiCaps LockControl  ft  */
  266.   KCF_NOP, KCF_NOP, KCF_NOP, KCF_NOP,
  267.   /* Left Alt Right Alt Left AmigaRight Amiga  */
  268.   KCF_NOP, KCF_NOP, KCF_NOP, KCF_NOP,
  269.   /* Rest are all nils */
  270.   KCF_NOP, KCF_NOP, KCF_NOP, KCF_NOP,
  271.   KCF_NOP, KCF_NOP, KCF_NOP, KCF_NOP,
  272.   KCF_NOP, KCF_NOP, KCF_NOP, KCF_NOP,
  273.   KCF_NOP, KCF_NOP, KCF_NOP, KCF_NOP
  274. };
  275.  
  276. ULONG HiKeyMap[64] =
  277. {
  278.   (ULONG)&key40, VANILJA('\b',0,0,0), (ULONG)&key42, VANILJA('\r',0,0,0),
  279.   VANILJA('\r','\n',0,0), VANILJA('\033','\233', 0, 0), /* ESC CSI */
  280.   VANILJA('\177','\037',0,0), 0L,
  281.   0L, 0L, '-', 0L,
  282.   (ULONG)&key4C, (ULONG)&key4D, (ULONG)&key4E, (ULONG)&key4F,
  283.   (ULONG)&key50, (ULONG)&key51, (ULONG)&key52, (ULONG)&key53,
  284.   (ULONG)&key54, (ULONG)&key55, (ULONG)&key56, (ULONG)&key57,
  285.   (ULONG)&key58, (ULONG)&key59,
  286.   VANILJA('[','{', '\033', '\033'), VANILJA(']','}', '\035', '\035'),
  287.   '/', '*', '+', (ULONG)&key5F,
  288.   0, 0, 0, 0, 0, 0, 0, 0,
  289.   0, 0, 0, 0, 0, 0, 0, 0,
  290.   0, 0, 0, 0, 0, 0, 0, 0,
  291.   0, 0, 0, 0, 0, 0, 0, 0
  292. };
  293.  
  294. UBYTE HiRepeatable[8] =
  295. {
  296.   /*   SPCBS TabEntRetEscDel NA */
  297.   BITS( 1, 1, 1, 0, 0, 0, 1, 0 ),
  298.   /*   NA NA p- NA Up DwnRgtLft */
  299.   BITS( 0, 0, 1, 0, 1, 1, 1, 1 ),
  300.   /*   F1 F2 F3 F4 F5 F6 F7 F8 */
  301.   BITS( 1, 1, 1, 1, 1, 1, 1, 1 ),
  302.   /*   F9F10 p[ p] p/ p* p+ LP */
  303.   BITS( 1, 1, 0, 0, 0, 0, 0, 0 ),
  304.   /*   60          -        67 */
  305.   BITS( 0, 0, 0, 0, 0, 0, 0, 0 ),
  306.   /*   68          -        6F */
  307.   BITS( 0, 0, 0, 0, 0, 0, 0, 0 ),
  308.   /*   70          -        77 */
  309.   BITS( 0, 0, 0, 0, 0, 0, 0, 0 )
  310. };
  311.  
  312. UBYTE HiCapsable[8] =
  313. {
  314.   /*   SPCBS TabEntRetEscDel NA */
  315.   BITS( 0, 0, 0, 0, 0, 0, 0, 0 ),
  316.   /*   NA NA p- NA Up DwnRgtLft */
  317.   BITS( 0, 0, 0, 0, 0, 0, 0, 0 ),
  318.   /*   F1 F2 F3 F4 F5 F6 F7 F8 */
  319.   BITS( 0, 0, 0, 0, 0, 0, 0, 0 ),
  320.   /*   F9 F10p[Fp] p/ p* p+ LP*/
  321.   BITS( 0, 0, 0, 0, 0, 0, 0, 0 ),
  322.   /*   60           -       67 */
  323.   BITS( 0, 0, 0, 0, 0, 0, 0, 0 ),
  324.   /*   68           -       6F */
  325.   BITS( 0, 0, 0, 0, 0, 0, 0, 0 ),
  326.   /*   70           -       77 */
  327.   BITS( 0, 0, 0, 0, 0, 0, 0, 0 )
  328. };
  329.  
  330. UBYTE KeyMapName[] = KEYMAPNAME;
  331.